public class Login {
    public String username = "whw";
    public String password = "123";

    public void LoginInfo(String username,String password) throws UserNameExcption,PassWordException{
        if (!this.username.equals(username)) {
            //System.out.println("用户名有问题");
            throw new UserNameExcption();
            //return;
        }
        if (!this.password.equals(password)) {
            throw new PassWordException();
//            System.out.println("密码出错");
//            return;
        }
        System.out.println("登录成功！！！");
    }

    public static void main(String[] args) {
        Login login = new Login();
        try {
            login.LoginInfo("whw","123");
        }catch (UserNameExcption userNameExcption){
            System.out.println("捕获了UserNameException 异常");
        }catch (PassWordException passWordException){
            System.out.println("捕获了PassWordException 异常");
        }

    }
}
